<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!--Pick up Orders-->
            <div class="table-outer">
                <h1 class="center-font">订单处理</h1><br>
                <c:if test="${orders.size() == 0}">
	                <div class="out-container">
					<div class="boo-wrapper">
						<div class="boo">
							<div class="face"></div>
						</div>
						<div class="shadow"></div>
						<h1>Sorry,您还没有订单哟~</h1>
					</div>
				</div>
               		
               	</c:if>
                <c:forEach var="o" items="${orders}">
	                <table class="table table-striped">
	                    <thead class="yellow-bg">
	                    <tr>
	                        <th>下单时间：${o.startTime}</th>
	                        <th>客户号码：${o.client.cTel}</th>
	                        <th colspan="2">配送地址：${o.client.cLocation}</th>
	                    </tr>
	                    </thead>
	                    <tbody>
	                    <tr><td colspan="4"><h4><b>订单菜品列表</b></h4></td></tr>
	                    <tr class="dish-header">
	                        <td>菜品名称</td>
	                        <td>单价/&yen;</td>
	                        <td>数量</td>
	                        <td>价格/&yen;</td>
	                    </tr>
	                    <c:forEach var="f" items="${o.foodlist}">
	                    <tr>
	                        <td>${f.fName }</td>
	                        <td>${f.fPrice }</td>
	                        <td>${f.num }</td>
	                        <td>${f.fPrice * f.num}</td>
	                    </tr>
	                    <c:set value="${sum + f.fPrice * f.num}" var="sum" />
	                    </c:forEach>
	                    <tr>
	                    	<td style="font-weight:bolder;">总计/&yen;：</td>
	                    	<td colspan="2"></td>
	                    	<td class="order-sum">${sum}</td>
	                    	<c:set value="0" var="sum" />
	                    </tr>
	                    <tr><td colspan="3"></td>
	                    <c:choose>
							<c:when test="${state == 2 }">
		                    	<td>
		                        	<a type="button" class="btn btn-common" href="${pageContext.request.contextPath }/homes/pickOrder?oid=${o.oId}">接单</a>
		                            <a type="button" class="btn btn-default" href="${pageContext.request.contextPath }/homes/abandonOrder?oid=${o.oId}">拒接</a>
		                        </td>
	                    	</c:when>
	                    	<c:otherwise>
		                    	<td>
		                        	<a type="button" class="btn btn-common" href="javascript:void(0)">接单</a>
		                            <a type="button" class="btn btn-default" href="javascript:void(0)">拒接</a>
		                        </td>
	                    	</c:otherwise>
	                    </c:choose>
	                    </tr>
	                    </tbody>
	                </table>
                </c:forEach>
            </div>
            
            
<script type="text/javascript">
	
	$(function() {
		
		setInterval (newOrders, 10000);/* 每10s刷一次 */
		
		function newOrders(){
			window.location.reload();
		}
		
	});
	
</script>